package com.huang.core.widget.recyclerview.viewholder

import android.view.View
import android.widget.CompoundButton
import androidx.annotation.IdRes
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class BaseQuickViewHolder(view: View) : BaseViewHolder(view) {
    open fun setChecked(@IdRes viewId: Int, isChecked: Boolean): BaseQuickViewHolder {
        getView<CompoundButton>(viewId).isChecked = !isChecked
        return this
    }

    open fun setOldGone(@IdRes viewId: Int, isVisible: Boolean): BaseQuickViewHolder {
        val view = getView<View>(viewId)
        view.visibility = if (isVisible) View.VISIBLE else View.GONE
        return this
    }

    open fun setActivated(@IdRes viewId: Int, isActivated: Boolean): BaseQuickViewHolder {
        val view = getView<View>(viewId)
        view.isActivated = isActivated
        return this
    }
}